using Admin2025.Application.Dtos;
using Admin2025.Application.DTOs;
using Admin2025.Application.IServices;
using Admin2025.Domain.Repositories;

namespace Admin2025.Application.Services;

public class PermissionService : IPermissionService
{
  private readonly IUserRepository _userRepository;

  public PermissionService(IUserRepository userRepository)
  {
    _userRepository = userRepository;
  }

  public async Task<IEnumerable<RoleDto>> GetUserRolesAsync(Guid userId)
  {
    var user = await _userRepository.GetByIdAsync(userId);
    return user?.Roles.Select(r => new RoleDto
    {
      RoleId = r.Id,
      RoleName = r.RoleName
    }) ?? Enumerable.Empty<RoleDto>();
  }
}